home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / infobots / Backup / MSOCache / All Users / 90000409-6000-11D3-8CFE-0150048383C9 / M3561414.CAB / OWSHLP10.CHM_1033 / html / ofvbanl.js < prev    next >
Text File  |  2003-05-07  |  3KB  |  84 lines

  1. ∩╗┐// ofvbanl.js
  2. // Purpose: Navigation hyperlink functions for Office VBA Help
  3. // Created: 09/01/1999 WadeT
  4. // Change history:
  5. // -Workaround for IE4 CSS height bug: do not set list height to 0, 10/12/99 WadeT
  6. // -Added addFavorites and lookupString functions, 10/13/99 WadeT
  7. // -Rename script file and changed to positioned IFrames, 11/2/99 WadeT
  8. // -Changed the offset for the popup to 15 (from 10), 06/13/00 Nick
  9.  
  10. // Global variables and constants
  11. var iDefHeight=200;    // Default height and width of hyperlink list popup window
  12. var iDefWidth=250;
  13. var iPopupOpen=false;    // Whether the popup window is visible
  14.  
  15. // Event handlers: Capture various window and document events
  16. window.onresize=closeList;
  17. window.onscroll=closeList;
  18. document.onclick=closeList;
  19. document.onkeypress=handleEnterPressed;
  20.  
  21. // Function: Translate Enter key press to mouse click
  22. function handleEnterPressed() {
  23.     window.event.cancelBubble=true;
  24.     if (window.event.keyCode==13) event.srcElement.click();
  25.     }
  26. // Function: Close navigation list pop up window
  27. function closeList() {
  28.     if (iPopupOpen) {
  29.         ofVBAISpan.style.display="none";
  30.         iPopupOpen=false;
  31.         }
  32.     }
  33. // Function: Show or hide the navigation list pop up window
  34. function toggleList() {
  35.     var iWidth=iDefWidth;
  36.     var iHeight=iDefHeight;
  37.     var oClicked=event.srcElement;
  38.     var iTop=oClicked.offsetTop+15;
  39.     var iLeft=oClicked.offsetLeft;
  40.     var coll=ofVBAIFrame.document.all.tags("DIV");
  41.     
  42.     // Make sure that events do not bubble up to parent handlers and close lists
  43.     window.event.cancelBubble=true;
  44.     closeList();
  45.     // Make the clicked DIVs visible and hide the others
  46.     if (coll.length) {
  47.         for (var i=0;i<coll.length;i++) {
  48.             if (coll[i].id.toLowerCase()==oClicked.id.toLowerCase()) {
  49.                 coll[i].style.display="inline";
  50.                 }
  51.             else {
  52.                 coll[i].style.display="none";
  53.                 }
  54.             }
  55.         }
  56.     ofVBAISpan.style.display="inline";
  57.  
  58.     while (oClicked.offsetParent.tagName.toLowerCase()!="body") {
  59.         oClicked = oClicked.offsetParent;
  60.         iTop+=oClicked.offsetTop;
  61.         iLeft+=oClicked.offsetLeft;
  62.         }
  63.  
  64.     with (document.body) {
  65.         // Adjust the horizontal position and width for narrow windows
  66.         if (iLeft+iWidth>scrollLeft+offsetWidth) iLeft=scrollLeft+offsetWidth-iWidth-20;
  67.         if (iLeft<scrollLeft) iLeft=scrollLeft;
  68.         if (iWidth>offsetWidth) iWidth=offsetWidth-20;
  69.         // Adjust the vertical position and height for short windows
  70.         if ((ofVBAISpan.offsetHeight>0)&&(ofVBAISpan.offsetHeight<iHeight)) iHeight=ofVBAISpan.offsetHeight;
  71.         if (iTop+iHeight>scrollTop+offsetHeight) iTop=scrollTop+offsetHeight-iHeight-20;
  72.         if (iTop<scrollTop) iTop=scrollTop;
  73.         if (iHeight>offsetHeight) iHeight=offsetHeight-20;
  74.         }
  75.     with (ofVBAISpan.style) {
  76.         // Position the popup window
  77.         pixelLeft=iLeft;
  78.         pixelTop=iTop;
  79.         pixelWidth=iWidth;
  80.         pixelHeight=iHeight;
  81.         }
  82.     iPopupOpen=true;
  83.     }
  84.